
#ifndef __msg_h__
#define __msg_h__

#pragma pack(push,1)
typedef struct
{
	unsigned char type;
	unsigned char size;
	union
	{
		unsigned char count;
		unsigned char be;
		unsigned char smmem;
	};

	unsigned char piggyback;
}HDR;


typedef struct msg_body_mread
{
	unsigned int address_lo;
	unsigned int address_hi;
}MSG_MREAD;
typedef struct msg_body_mwrite
{
	unsigned int address_lo;
	unsigned int address_hi;
	unsigned char buff[1];
}MSG_MWRITE;

typedef struct msg_body_ioread
{
	unsigned short address;
}MSG_IOREAD;

typedef struct msg_body_iowrite
{
	unsigned short address;
	unsigned char buff[1];
}MSG_IOWRITE;
typedef struct
{
	HDR hdr;
	union body
	{
		MSG_MREAD mread;
		MSG_MWRITE mwrite;
		MSG_IOREAD ioread;
		MSG_IOWRITE iowrite;
	} u;
} PIPE_MSG;



#pragma pack(pop)
int rpc_call(PIPE_MSG *msg,char * reply);

#define MREAD   0
#define MWRITE  1
#define IOREAD  2
#define IOWRITE 3
#define INTA    4
#define SMIACK  5
#define MREADBE   6
#define MWRITEBE  7
#define IOREADBE  8
#define IOWRITEBE 9
#define REPLY   10

#define SIZE_MREAD   (sizeof(HDR)+sizeof(MSG_MREAD))
#define SIZE_MWRITE  (sizeof(HDR)+sizeof(MSG_MWRITE)-1)
#define SIZE_IOREAD  (sizeof(HDR)+sizeof(MSG_IOREAD))
#define SIZE_IOWRITE (sizeof(HDR)+sizeof(MSG_IOWRITE)-1)
#define SIZE_INTA    (sizeof(HDR))
#define SIZE_SMIACK  (sizeof(HDR))
#define SIZE_REPLY   (sizeof(HDR))

#define BUFSIZE 64
#endif